# include <bits/stdc++.h>
# define N 3000005
using namespace std;
bool ok[25][1048576];
int main()
{
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);
    string s;
    cin>>s;
    int n=s.size();
    if(n>20)
    {
        if(s[0]=='A')
            cout<<(n+1)/2<<endl;
        if(s[0]=='B')
            cout<<(n+2)/2<<endl;
        return 0;
    }
    int S=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='B')
            S+=(1<<i);
    ok[n][S]=1;
    for(int len=n;len>=1;len-=2)
        for(int S=0;S<(1<<len);S++)
            if(ok[len][S])
                for(int i=0;i<len-1;i++)
                    if((S>>i&1) || !(S>>(i+1)&1))
                        ok[len-2][((S>>(i+2))<<i)+(S&((1<<i)-1))]=1;
    int ans=0;
    for(int i=n%2;i<=n;i+=2)
        for(int S=0;S<=(1<<i);S++)
            ans+=ok[i][S];
    cout<<ans<<endl;
    return 0;
}